import json
import requests
import datetime
import time

loginUrl = 'https://nbj.sgmw.com.cn/dmscloud.sysAuth/login'#登录的网址
#authUrl='https://nbj.sgmw.com.cn/dmscloud.sysAuth/login/initUserData?password=Liu3699%&Liu3699%=&_=1595054470490'#登录认证的网址
authUrl='https://nbj.sgmw.com.cn/dmscloud.sysAuth/login/initUserData'#登录认证的网址
queryUrl='https://nbj.sgmw.com.cn/dmscloud.cluePC/ReportManagementInfo/queryClue'#查询的网址



# payloadData数据
loginData = {
    'username': '13974810178',
    'password': 'Liu3699%'
}
# 请求头设置

headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36"
    }

s = requests.Session()#网页请求
s.headers.update(headers)#网页请求头信息
# 下面这种直接填充json参数的方式也OK
baojunRes = s.post(loginUrl, json=loginData)#登录
# print(
#     f"responseTime = {datetime.datetime.now()}, statusCode = {res.status_code}, res text = {res.text}")


millis = str(int(round(time.time()*1000)))#获取13位的时间戳
authData={
    'password':'Liu3699%25',
    'Liu3699%':'',
    '_': millis
}

auth = s.get(authUrl, params=authData)


millis = str(int(round(time.time()*1000)))#获取13位的时间戳
queryata={
    'dmsFuncId': 166011,
    'order': 'DESC',
    'limit': 10,
    'offset': 0,
    'filtrationdealer': 't',
    'issuedStart': '2020-07-18',
    'issuedEnd': '2020-07-18',
    'staut': '70001001',
    'invitations': '',
    'dmsFuncId': '166011',
    '_': millis
}


resget = s.get(queryUrl, params=queryata)
print (resget.status_code)
print (resget.text)

#查询线索
#没https://nbj.sgmw.com.cn/dmscloud.cluePC/ReportManagementInfo/queryClue?dmsFuncId=166011&order=DESC&limit=10&offset=0&filtrationdealer=t&issuedStart=2020-07-18&issuedEnd=2020-07-18&staut=70001001&invitations=&dmsFuncId=166011&_=1595035168072
#有https://nbj.sgmw.com.cn/dmscloud.cluePC/ReportManagementInfo/queryClue?dmsFuncId=166011&order=DESC&limit=10&offset=0&filtrationdealer=t&issuedStart=2020-07-18&issuedEnd=2020-07-18&staut=70001001&invitations=&dmsFuncId=166011&_=1595035168073
#{"total":0,"rows":[]}
#{"total":2,"rows":[{"ACTUAL_VISIT_DATE":null,"BRAND_ID":2000000015,"BRAND_NAME":"新宝骏","CITY":"长沙市","CLUE_BELONG":"本店","CLUE_STATUS":70001001,"CLUE_TYPE":"厂发","CONTACT_DATE":"","CUSTOMER_NAME":"张新","DEALER_CODE":"-1","DEALER_CODETWO":"B430005","DEALER_ID":2860,"DEALER_NAME":"湖南湘骏汽车销售服务有限公司","DEFEAT_REASON":"","DISTRIBUTION_DATE":null,"EMPLOYEE_NAME":null,"FIRST_CONTACT_DATE":null,"GENDER":"10021002","INTE_CAR_SERIES":3000000282,"INTENT_LEVEL":null,"INVALID_REASON":null,"IS_ARRIVED":10041002,"ISSUED_DATE":"2020-07-18 10:07:21","LAST_CONTACT_DATE":null,"LEAD_ID":"01191123221257522802","MANAGE_SYSTEM_CODE":"B430005","MANAGE_SYSTEM_SHORTNAME":"湖南湘骏","MOBILE_PHONE":"13707480452","ONE_LEVEL_LABEL":"电商平台","PROVINCE":"湖南省","REGION":"中南区","SERIES_NAME":"新宝骏RC-6","SOURCE_ACTIVITY":"电商活动","SYSTEM_CODE":"9450088","SYSTEM_SHORTNAME":"柳州市双新","THREE_LEVEL_LABEL":"电商-京东","TWO_LEVEL_LABEL":"京东","UP_DEALER":null,"UP_DEALER_NAME":null},{"ACTUAL_VISIT_DATE":null,"BRAND_ID":2000000015,"BRAND_NAME":"新宝骏","CITY":"长沙市","CLUE_BELONG":"本店","CLUE_STATUS":70001001,"CLUE_TYPE":"厂发","CONTACT_DATE":"","CUSTOMER_NAME":"张征兵","DEALER_CODE":"-1","DEALER_CODETWO":"B430005","DEALER_ID":2860,"DEALER_NAME":"湖南湘骏汽车销售服务有限公司","DEFEAT_REASON":"","DISTRIBUTION_DATE":null,"EMPLOYEE_NAME":null,"FIRST_CONTACT_DATE":null,"GENDER":"10021001","INTE_CAR_SERIES":3000000282,"INTENT_LEVEL":null,"INVALID_REASON":null,"IS_ARRIVED":10041002,"ISSUED_DATE":"2020-07-18 10:07:22","LAST_CONTACT_DATE":null,"LEAD_ID":"05180404267149132804","MANAGE_SYSTEM_CODE":"B430005","MANAGE_SYSTEM_SHORTNAME":"湖南湘骏","MOBILE_PHONE":"13707490776","ONE_LEVEL_LABEL":"电商平台","PROVINCE":"湖南省","REGION":"中南区","SERIES_NAME":"新宝骏RC-6","SOURCE_ACTIVITY":"电商活动","SYSTEM_CODE":"9450088","SYSTEM_SHORTNAME":"柳州市双新","THREE_LEVEL_LABEL":"电商-京东","TWO_LEVEL_LABEL":"京东","UP_DEALER":null,"UP_DEALER_NAME":null}]}
#{"errorMsg":"错误原因:用户未登录"}
'''
没有
dmsFuncId: 166011
order: DESC
limit: 10
offset: 0
filtrationdealer: t
issuedStart: 2020-07-18
issuedEnd: 2020-07-18
staut: 70001001
invitations: 
dmsFuncId: 166011
_: 1595035168072

有
dmsFuncId: 166011
order: DESC
limit: 10
offset: 0
filtrationdealer: t
issuedStart: 2020-07-18
issuedEnd: 2020-07-18
staut: 70001001
invitations: 
dmsFuncId: 166011
_: 1595035168073

dmsFuncId: 166011
order: DESC
limit: 10
offset: 0
filtrationdealer: t
issuedStart: 2020-07-18
issuedEnd: 2020-07-18
staut: 70001001
invitations: 
dmsFuncId: 166011
_: 1595039518754

dmsFuncId: 166011
order: DESC
limit: 10
offset: 0
filtrationdealer: t
issuedStart: 2020-07-18
issuedEnd: 2020-07-18
staut: 70001001
invitations: 
dmsFuncId: 166011
_: 1595041302317

'''